#ifndef CT_RABBITMQ_PUSH_THREAD_H_
#define CT_RABBITMQ_PUSH_THREAD_H_

#include "ctRWLock.h"
#include "ct_thread.h"
#include "amqp.h"
#include "ctRWLock.h"
#include <stdint.h>
#include <vector>

class AMQPPushThread:
        public ctThread
{
        public:
                virtual ~AMQPPushThread();
                void init(const std::string &host, 
                                const uint16_t &port, 
                                const std::string &user, 
                                const std::string &pswd, 
                                const std::string &vhost,
                                const std::string &exchange, 
                                const std::string &routingkey);
                void run();
                void snd_msg(const std::string &msg);

        private:
                void loop_push_msg(amqp_connection_state_t conn);
                void push_msg(const std::string &msg);
                bool pop_msg(std::string &msg);

                std::string hostname_;
                uint16_t port_;
                std::string vhost_;
                std::string user_;
                std::string passwd_;
                std::string exchange_;
                std::string routingkey_;

                std::vector<std::string> msg_queue_;
                ctRWLock msg_lock_;
};

#endif
